const pool = require('../utils/utils.js')

module.exports = async(ctx, next) => {
    var category = ctx.query.category
    var sql = `select * from book where category="${category}"`
    var res = await new Promise((resolve, reject) => {
        pool.query(sql, (err, result) => {
            if (err) {
                reject(err)
            } else {
                resolve(result)
            }
        })
    })
    ctx.body = res
    await next()
}